#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mem(x) memset(x,0,sizeof(x))
#define endl "\n"
#define printYes cout << "Yes\n"
#define printYES cout << "YES\n"
#define printNo cout << "No\n"
#define printNO cout << "NO\n"
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define mkp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,j,k) for (int i=(j);i<=(k);i++)
#define per(i,j,k) for (int i=(j);i>=(k);i--)
#define pcnt(x) __builtin_popcount(x)
mt19937 rnd(time(0));
template<class T>void chkmin(T&x,T y){x=min(x,y);}
template<class T>void chkmax(T&x,T y){x=max(x,y);}


const int inf=1000000000;
//const ll mod=998244353;
//const ll mod=1000000007;

const int N=1e5+5;
int n;
vector<int>t[N];
priority_queue<int>q[N];
void merge(int x,int y)
{
	bool flag=0;
	if (SZ(q[x])>SZ(q[y])) swap(x,y),flag=1;
	while (SZ(q[x])) q[y].push(q[x].top()),q[x].pop();
	if (flag) swap(q[x],q[y]);
}
void dfs(int x,int f)
{
	for (int i:t[x])
	{
		if (i==f) continue;
		dfs(i,x);
		merge(i,x);
	}
	if (SZ(q[x])==0) q[x].push(1);
	else if (SZ(q[x])==1) 
	{
		int a=q[x].top();
		q[x].pop();
		a++;
		q[x].push(a);
	}
	else 
	{
		int a=q[x].top();
		q[x].pop();
		int b=q[x].top();
		q[x].pop();
		if ((a%2==0)&&(b%2==0)) 
		{
			q[x].push(a+b);
			q[x].push(1);
		}
		else q[x].push(a+b+1);
	}
}

int main()
{
	freopen("bird.in","r",stdin);
	freopen("bird.out","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin >> n;
	rep(i,1,n-1)
	{
		int x,y;
		cin >> x >> y;
		t[x].pb(y),t[y].pb(x);
	}
	dfs(1,0);
	cout << q[1].top();
	return 0;
}
